package smartcrud.spring.models.crud;

import java.io.Serializable;
import java.util.Date;

import org.apache.commons.lang.builder.ToStringBuilder;

import smartcrud.common.utils.ImageUtil;

public class Hello implements Serializable {
	/**
	 * 
	 */
	private static final long serialVersionUID = 1L;
	private Long id;
	private String name;
	private Integer age;
	private Double money;
	private Boolean atWork;
	private byte[] icon;
	
	//for Inline Images with Data URLs
	private String imgSrc;
	
	private String introduce;
	private Date createDate;

	public Long getId() {
		return id;
	}

	public void setId(Long id) {
		this.id = id;
	}

	public String getName() {
		return name;
	}

	public void setName(String name) {
		this.name = name;
	}

	
	
	public Integer getAge() {
		return age;
	}

	public void setAge(Integer age) {
		this.age = age;
	}

	public Double getMoney() {
		return money;
	}

	public void setMoney(Double money) {
		this.money = money;
	}

	public Boolean getAtWork() {
		return atWork;
	}

	public void setAtWork(Boolean atWork) {
		this.atWork = atWork;
	}

	public byte[] getIcon() {
		return icon;
	}

	public void setIcon(byte[] icon) {
		this.icon = icon;
	}
	
	public String getImgSrc() {
		//http://stackoverflow.com/questions/469695/decode-base64-data-in-java
		//http://www.oschina.net/code/snippet_54100_3726
		if (icon!=null) {
			if (imgSrc==null) {
				imgSrc = ImageUtil.bytes2HtmlImgTag(icon);
			}
			return imgSrc;
		}
		
		return null;
	}

	public String getIntroduce() {
		return introduce;
	}

	public void setIntroduce(String introduce) {
		this.introduce = introduce;
	}

	public Date getCreateDate() {
		return createDate;
	}

	public void setCreateDate(Date createDate) {
		this.createDate = createDate;
	}

	@Override
	public String toString() {
		return ToStringBuilder.reflectionToString(this);
	}
}
